<template>
    <div style="padding:10px;">
        <el-tabs v-model="activeName" @tab-click="handleClick">
            <el-tab-pane label="基本信息" name="基本信息">
                <section>
                    <baseForm ref="基本信息"></baseForm>
                    <div>
                        <el-button
                                :loading="loading"
                                type="primary" @click="triggerBaseForm"> 保存
                        </el-button>
                    </div>
                </section>
            </el-tab-pane>
            <el-tab-pane label="表单设置" name="表单设置">
                <section>
                    <formSetting ref="表单设置"></formSetting>
                </section>
            </el-tab-pane>
            <el-tab-pane label="流程图设置" name="流程图设置">
                <bnpmSetting ref="流程图设置" v-if="activeName==='流程图设置'"> </bnpmSetting>
            </el-tab-pane>
        </el-tabs>
    </div>
</template>
<script>
  import { getUrlParam } from '@/utils/index.js';
  
  export default {
    data() {
      return {
        loading: false,
        activeName: '基本信息',
      };
    },
    components: {
      'baseForm': () => import('@/views/bnpmList/components/modifyForm.vue'),
      'formSetting': () => import('@/views/bnpmList/form/list.vue'),
      'bnpmSetting': () => import('@/views/bnpmList/bnpm/one.vue'),
    },
    mounted() {
      setTimeout(() => {
        this.$refs['基本信息'].initByDialog({
          id: getUrlParam('bpmId'),
        });
      }, 300);
    },
    methods: {
      handleClick() {
        var currentName = this.activeName;
        setTimeout(() => {
          this.$refs[currentName].initByDialog({
            id: getUrlParam('bpmId'),
            bpmId: getUrlParam('bpmId'),
          });
        },300)
     
      },
      async triggerBaseForm() {
        this.loading = true;
        await this.$refs['基本信息'].submitByDialog();
        this.loading = false;
      },
      async triggerFormSave(){
        this.loading = true;
        await this.$refs['表单设置'].submitByDialog();
        this.loading = false;
      }
    },
  };
</script>
